package com.ZengQi.event.controller;

import com.ZengQi.event.entity.Admin;
import com.ZengQi.event.entity.Company;
import com.ZengQi.event.service.AdminService;
import com.ZengQi.event.service.CompanyService;
import com.ZengQi.event.service.impl.AdminServiceImpl;
import com.ZengQi.event.service.impl.CompanyServiceImpl;

import java.util.List;

public class UpdateCompanyController {
    private CompanyService companyService=new CompanyServiceImpl();
    private AdminService adminService=new AdminServiceImpl();

    public boolean update(Company company, Admin admin,String oldCompanyName){
        boolean x1=companyService.modifyCompanyByCompanyName(company,oldCompanyName);
        boolean x2=adminService.modifyAdminByOldCompanyName(admin,oldCompanyName);

        return x1||x2;
    }
    public boolean companyNameIsExit(Company conditionCompany){
        List<Company> listCompany = companyService.findListCompany();
        for(Company company:listCompany){
            if(company.getCompanyName().equals(conditionCompany.getCompanyName())){
                return true;
            }

        }
        return false;
    }
}
